package com.zhangyu.shadow.repair.delegate.history.detail;

import com.zhangyu.shadow.repair.base.IStringDataConvert;
import com.zhangyu.shadow.repair.delegate.bean.HistoryDataBean;

import org.greenrobot.greendao.annotation.NotNull;

import st.lib.base.net.callback.IError;

/**
 * @author zhangyu
 * @date 2018/12/5
 */

public class HistoryDetailPresenter extends HistoryDetailContract.Presenter {
    private final HistoryDetailContract.View mView;
    private final HistoryDetailContract.Model mModel;

    public HistoryDetailPresenter(@NotNull HistoryDetailContract.View view) {
        mView = view;
        mModel = new HistoryDetailModel();
    }

    @Override
    void getHistoryData(String id, String type) {
        addDisposable(mModel.getHistoryData(id, type,
                new IStringDataConvert<HistoryDataBean>() {
                    @Override
                    public void convert(HistoryDataBean o) {
                        if (mView != null) {
                            mView.showHistoryList(o);
                        }
                    }
                }, new IError() {
                    @Override
                    public void onError(int code, String msg) {

                    }
                }));
    }
}
